package core;


/**
 * 错误码 + 错误提示 控制
 */
public final class ErrorMsgUtil {

    public static final String STATUS_NET_ERROR = "-10001";//网络链接错误
    public static final String ERR_MSG_NET_ERROR = "网络貌似不给力～\n请检查你的网络后重试";

    public static final String STATUS_JSON_PARSE_ERROR = "-10002";//JSON解析错误
    public static final String ERR_MSG_JSON_PARSE_ERROR = "服务器出了一个问题~\n请稍后再试";

    public static final String STATUS_INNER_ERROR = "-10004";//内部错误
    public static final String ERR_MSG_INNER_ERROR = "服务器出了一个问题~\n请稍后再试";

    /**
     * 网络错误
     */
    public static void renderNetworkErrorMsg(DataResponse response) {
        response.status = STATUS_NET_ERROR;
        response.errmsg = ERR_MSG_NET_ERROR;
    }

    /**
     * json解析错误
     */
    public static void renderJSONParseErrorMsg(DataResponse response) {
        response.status = STATUS_JSON_PARSE_ERROR;
        response.errmsg = ERR_MSG_JSON_PARSE_ERROR;
    }

    /**
     * 内部错误
     *
     * @return
     */
    public static void renderInnerErrorMsg(DataResponse response) {
        response.status = STATUS_INNER_ERROR;
        response.errmsg = ERR_MSG_INNER_ERROR;
    }
}
